home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / tcp / AmigaTCP.lha / AmigaTCP / src / arp.h < prev    next >
C/C++ Source or Header  |  1989-06-24  |  3KB  |  75 lines

  1. /* Size of ARP hash table */
  2. #define    ARPSIZE    17
  3.  
  4. /* Lifetime of a valid ARP entry (seconds) */
  5. #define    ARPLIFE        (15*60)    /* 15 minutes */
  6. /* Lifetime of a pending ARP entry (seconds) */
  7. #define    PENDTIME    15    /* 15 seconds */
  8.  
  9. /* ARP definitions (see RFC 826) */
  10.  
  11. /* Address size definitions */
  12. #define    IPALEN    4        /* Length in bytes of an IP address */
  13. #define    MAXHWALEN    255    /* Maximum length of a hardware address */
  14.  
  15. /* ARP opcodes */
  16. #define    ARP_REQUEST    1
  17. #define    ARP_REPLY    2
  18.  
  19. /* Hardware types */
  20. #define    ARP_ETHER    1    /* Assigned to 10 megabit Ethernet */
  21. #define    ARP_EETHER    2    /* Assigned to experimental Ethernet */
  22. #define    ARP_AX25    3    /* Assigned to AX.25 Level 2 */
  23. #define    ARP_PRONET    4    /* Assigned to PROnet token ring */
  24. #define    ARP_CHAOS    5    /* Assigned to Chaosnet */
  25. #define    ARP_ARCNET    7
  26.  
  27. /* Table of hardware types known to ARP */
  28. struct arp_type {
  29.     int hwalen;        /* Hardware length */
  30.     int iptype;        /* Hardware type field for IP */
  31.     int arptype;        /* Hardware type field for ARP */
  32.     char *bdcst;        /* Hardware broadcast address */
  33.     int (*format)();    /* Function that formats addresses */
  34.     int (*scan)();        /* Reverse of format */
  35. };
  36. extern struct arp_type arp_type[];
  37.  
  38. /* Format of an ARP request or reply packet. From p. 3 */
  39. struct arp {
  40.     int16 hardware;            /* Hardware type */
  41.     int16 protocol;            /* Protocol type */
  42.     unsigned char hwalen;        /* Hardware address length, bytes */
  43.     unsigned char pralen;        /* Length of protocol address */
  44.     int16 opcode;            /* ARP opcode (request/reply) */
  45.     char shwaddr[MAXHWALEN];    /* Sender hardware address field */
  46.     int32 sprotaddr;        /* Sender Protocol address field */
  47.     char thwaddr[MAXHWALEN];    /* Target hardware address field */
  48.     int32 tprotaddr;        /* Target protocol address field */
  49. };
  50.         
  51. /* Format of ARP table */
  52. struct arp_tab {
  53.     struct arp_tab *next;    /* Doubly-linked list pointers */
  54.     struct arp_tab *prev;    
  55.     int32 ip_addr;        /* IP Address, host order */
  56.     int16 hardware;        /* Hardware type */
  57.     char *hw_addr;        /* Hardware address */
  58.     char state;        /* (In)complete */
  59. #define    ARP_PENDING    0
  60. #define    ARP_VALID    1
  61.     struct timer timer;    /* Time until aging this entry */
  62.     struct mbuf *pending;    /* Queue of datagrams awaiting resolution */
  63. };
  64. #define    NULLARP    (struct arp_tab *)NULL
  65. extern struct arp_tab *arp_tab[];
  66.  
  67. struct arp_stat {
  68.     int recv;    /* Total number of ARP packets received */
  69.     int badtype;    /* Incoming requests for unsupported hardware */
  70.     int badlen;    /* Incoming length field(s) didn't match types */
  71.     int inreq;    /* Incoming requests for us */
  72.     int replies;    /* Replies sent */
  73.     int outreq;    /* Outoging requests sent */
  74. };
  75.